import 'dart:convert';

class PmtM {
  PmtM({
    required this.id,
    required this.areaId,
    required this.areaName,
    required this.title,
    required this.picturePath,
    required this.pictureId,
    required this.link,
    required this.position,
    required this.isThird,
    required this.thirdCode,
    required this.source,
    required this.isCountDown,
    required this.countDownTime,
    required this.isShow,
    required this.advWechatId,
    required this.linkType,
    required this.delayDisplay,
  });

  PmtM.fromJson(dynamic json) {
    id = json['id']??'';
    areaId = json['area_id']??'';
    areaName = json['area_name']??'';
    title = json['title']??'';
    picturePath = json['picture_path']??'';
    pictureId = json['picture_id']??'';
    link = json['link']??'';
    position = json['position']??'home_popup_list';
    isThird = json['is_third']??'';
    thirdCode = json['third_code']??"";
    source = json['source']??'common';
    isCountDown = json['is_count_down']??1;
    countDownTime = json['count_down_time']??3;
    isShow = json['is_show']??2;
    advWechatId = json['adv_wechat_id']??'';
    linkType = json['link_type']??0;
    delayDisplay = json['delay_display']??0;
  }

  late String id;
  late String areaId;
  late String areaName;
  late String title;
  late String picturePath;
  late String pictureId;
  late String link;
  late String position;
  late num isThird;
  late String thirdCode;
  late String source;
  late num isCountDown;
  late num countDownTime;
  late num isShow;
  late String advWechatId;
  late num linkType;
  late num delayDisplay;

  PmtM copyWith({
    String? id,
    String? areaId,
    String? areaName,
    String? title,
    String? picturePath,
    String? pictureId,
    String? link,
    String? position,
    num? isThird,
    String? thirdCode,
    String? source,
    num? isCountDown,
    num? countDownTime,
    num? isShow,
    String? advWechatId,
    num? linkType,
    num? delayDisplay,
  }) =>
      PmtM(
        id: id ?? this.id,
        areaId: areaId ?? this.areaId,
        areaName: areaName ?? this.areaName,
        title: title ?? this.title,
        picturePath: picturePath ?? this.picturePath,
        pictureId: pictureId ?? this.pictureId,
        link: link ?? this.link,
        position: position ?? this.position,
        isThird: isThird ?? this.isThird,
        thirdCode: thirdCode ?? this.thirdCode,
        source: source ?? this.source,
        isCountDown: isCountDown ?? this.isCountDown,
        countDownTime: countDownTime ?? this.countDownTime,
        isShow: isShow ?? this.isShow,
        advWechatId: advWechatId ?? this.advWechatId,
        linkType: linkType ?? this.linkType,
        delayDisplay: delayDisplay ?? this.delayDisplay,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['area_id'] = areaId;
    map['area_name'] = areaName;
    map['title'] = title;
    map['picture_path'] = picturePath;
    map['picture_id'] = pictureId;
    map['link'] = link;
    map['position'] = position;
    map['is_third'] = isThird;
    map['third_code'] = thirdCode;
    map['source'] = source;
    map['is_count_down'] = isCountDown;
    map['count_down_time'] = countDownTime;
    map['is_show'] = isShow;
    map['adv_wechat_id'] = advWechatId;
    map['link_type'] = linkType;
    map['delay_display'] = delayDisplay;
    return map;
  }
}


List<PmtM> pmtMListFromJson(String str) =>
    List<PmtM>.from(
        json.decode(str).map((x) => PmtM.fromJson(x)));
